package com.stake.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

import com.google.appengine.api.datastore.Key;
import com.stake.model.ActivityTypesEnum;

@PersistenceCapable
public class UserInfo implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L; 
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	@Persistent
	@Unique(name="USERNAME_IDX")
	private String userName;
	@Persistent
	private String password;
	@Persistent
	private String firstName;
	@Persistent
	private String lastName;
	@Persistent
	private String companyName;
	@Persistent
	private String companyWebsite;
	@Persistent
	private String email;
	@Persistent
	private Boolean enabled;
	@Persistent
	private List<String> authorities;
	@Persistent
	private Long lastTimeStampMillis;
	@Persistent
	private Boolean qanswered;
	@Persistent
	private String linkedInAccessToken;
	@Persistent
	private String linkedInTokenSecret;
	@Persistent
	private Date linkedInTokenExpiry;
	@Persistent
	private String imageBlobKey;
	@Persistent
	private Boolean isCompany;
	@Persistent
	private List<String> activityTypes;
	@Persistent
	private Boolean isUserOnlyForSearch;
	@Persistent
	private Date dateOfBirth;
	@Persistent
	private Integer gender; // 1 for male | 2 for female
	
	@Persistent
	private String profilePictureUrl;
	
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the authorities
	 */
	public List<String> getAuthorities() {
		return authorities;
	}
	/**
	 * @param authorities the authorities to set
	 */
	public void setAuthorities(List<String> authorities) {
		this.authorities = authorities;
	}
	/**
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}
	/**
	 * @param key the key to set
	 */
	public void setKey(Key key) {
		this.key = key;
	}
	/**
	 * @return the enabled
	 */
	public Boolean getEnabled() {
		return enabled;
	}
	
	/**
	 * @return the enabled
	 */
	public Boolean isEnabled() {
		return enabled;
	}
	
	/**
	 * @param enabled the enabled to set
	 */
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	/**
	 * @return the lastTimeStampMillis
	 */
	public Long getLastTimeStampMillis() {
		return lastTimeStampMillis;
	}
	/**
	 * @param lastTimeStampMillis the lastTimeStampMillis to set
	 */
	public void setLastTimeStampMillis(Long lastTimeStampMillis) {
		this.lastTimeStampMillis = lastTimeStampMillis;
	}
	/**
	 * @return the qanswered
	 */
	public Boolean getQanswered() {
		return qanswered;
	}
	/**
	 * @param qanswered the qanswered to set
	 */
	public void setQanswered(Boolean qanswered) {
		this.qanswered = qanswered;
	}
	/**
	 * @return the linkedInAccessToken
	 */
	public String getLinkedInAccessToken() {
		return linkedInAccessToken;
	}
	/**
	 * @param linkedInAccessToken the linkedInAccessToken to set
	 */
	public void setLinkedInAccessToken(String linkedInAccessToken) {
		this.linkedInAccessToken = linkedInAccessToken;
	}
	/**
	 * @return the linkedInTokenSecret
	 */
	public String getLinkedInTokenSecret() {
		return linkedInTokenSecret;
	}
	/**
	 * @param linkedInTokenSecret the linkedInTokenSecret to set
	 */
	public void setLinkedInTokenSecret(String linkedInTokenSecret) {
		this.linkedInTokenSecret = linkedInTokenSecret;
	}
	/**
	 * @return the linkedInTokenExpiry
	 */
	public Date getLinkedInTokenExpiry() {
		return linkedInTokenExpiry;
	}
	/**
	 * @param linkedInTokenExpiry the linkedInTokenExpiry to set
	 */
	public void setLinkedInTokenExpiry(Date linkedInTokenExpiry) {
		this.linkedInTokenExpiry = linkedInTokenExpiry;
	}
	/**
	 * @return the imageBlobKey
	 */
	public String getImageBlobKey() {
		return imageBlobKey;
	}
	/**
	 * @param imageBlobKey the imageBlobKey to set
	 */
	public void setImageBlobKey(String imageBlobKey) {
		this.imageBlobKey = imageBlobKey;
	}
	/**
	 * @return the profilePictureUrl
	 */
	public String getProfilePictureUrl() {
		return profilePictureUrl;
	}
	/**
	 * @param profilePictureUrl the profilePictureUrl to set
	 */
	public void setProfilePictureUrl(String profilePictureUrl) {
		this.profilePictureUrl = profilePictureUrl;
	}
	/**
	 * @return the isCompany
	 */
	public Boolean getIsCompany() {
		return isCompany;
	}
	/**
	 * @param isCompany the isCompany to set
	 */
	public void setIsCompany(Boolean isCompany) {
		this.isCompany = isCompany;
	}
	/**
	 * @return the activityTypes
	 */
	public List<String> getActivityTypes() {
		return activityTypes;
	}
	/**
	 * @param activityTypes the activityTypes to set
	 */
	public void setActivityTypes(List<String> activityTypes) {
		this.activityTypes = activityTypes;
	}
	/**
	 * @return the isUserOnlyForSearch
	 */
	public Boolean getIsUserOnlyForSearch() {
		return isUserOnlyForSearch;
	}
	/**
	 * @param isUserOnlyForSearch the isUserOnlyForSearch to set
	 */
	public void setIsUserOnlyForSearch(Boolean isUserOnlyForSearch) {
		this.isUserOnlyForSearch = isUserOnlyForSearch;
	}
	
	public boolean isProvider(String[] providingActivities){
		for(String act : providingActivities){
			if(activityTypes.contains(act)){
				return true;
			}
		}
		return false;
	}
	
	public List<String> getActivityTypeValues(){
		List<String > resultList = new ArrayList<String>();
		for(String act :  getActivityTypes()){
			resultList.add(ActivityTypesEnum.getValueByName(act));
		}
		return resultList;
	}
	/**
	 * @return the companyName
	 */
	public String getCompanyName() {
		return companyName;
	}
	/**
	 * @param companyName the companyName to set
	 */
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	/**
	 * @return the companyWebsite
	 */
	public String getCompanyWebsite() {
		return companyWebsite;
	}
	/**
	 * @param companyWebsite the companyWebsite to set
	 */
	public void setCompanyWebsite(String companyWebsite) {
		this.companyWebsite = companyWebsite;
	}
	/**
	 * @return the dateOfBirth
	 */
	public Date getDateOfBirth() {
		return dateOfBirth;
	}
	/**
	 * @param dateOfBirth the dateOfBirth to set
	 */
	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	/**
	 * @return the gender
	 */
	public Integer getGender() {
		return gender;
	}
	/**
	 * @param gender the gender to set
	 */
	public void setGender(Integer gender) {
		this.gender = gender;
	}

}
